#include "../include/debug_info.hpp"

#include <WiFi.h>
#include <WiFiClient.h>

WiFiServer tcp_server(23);
WiFiClient tcp_client;

static void tcp_init(){
    tcp_server.begin();
}

static void send(String data){
    if (tcp_server.hasClient()) {
        tcp_client = tcp_server.available();
    }
    tcp_client.print(data);
}

static void tcp_loop(void){
    if (tcp_server.hasClient()) {
        tcp_client = tcp_server.available();
        tcp_client.print(tcp_client.readString());
    }
}

static DBG_OPS ops = {
    .init = tcp_init,
    .send = send,
    .loop = tcp_loop,
};

DBG dbg = {
    .ops = &ops,
};
